Skip to content

Conversation

chopan050
Copy link
Contributor

Overview: What does this pull request change?

Refactored imports from collections.abc, typing and typing_extensions. This PR is valid as long as we support Python 3.9. Changes might need to be done in the future after dropping support for that version.

Motivation and Explanation: Why and how do your changes improve the library?

  • typing.Callable is a deprecated alias for collections.abc.Callable, which is why I used the latter instead.
  • There were some imports of Any from typing_extensions when it's perfectly possible to import it from typing (unless we used Any as a base class, which we don't), so I did the latter instead.
  • Sometimes, import typing was used instead of from typing import X, Y, Z. Sometimes, both kinds of imports were present in a file at the same time, or there were multiple from typing import X, Y, Z lines in different parts of the code, so I cleaned them.
  • There was an import collections line in order to use collections.abc.Hashable and collections.abc.Iterable. In the same file, there was an import typing to use typing.Callable and other things, so I replaced the previous lines with from collections.abc import Callable, Hashable, Iterable.
  • There was an import collections line in order to use collections.defaultdict, but other files simply used from collections import defaultdict, so I used the latter for consistency.

Links to added or changed documentation pages

Further Information and Comments

Reviewer Checklist

  • The PR title is descriptive enough for the changelog, and the PR is labeled correctly
  • If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
  • If applicable: newly added functions and classes are tested

@@ -234,7 +233,7 @@
# Serialize it with only the type of the object. You can change this to whatever string when debugging the serialization process.
return str(type(obj))

def _cleaned_iterable(self, iterable: typing.Iterable[Any]):
def _cleaned_iterable(self, iterable: Iterable[Any]):

Check notice

Code scanning / CodeQL

Explicit returns mixed with implicit (fall through) returns Note

Mixing implicit and explicit returns may indicate an error, as implicit returns always return None.
@chopan050 chopan050 added the maintenance refactoring, typos, removing clutter/dead code, and other code quality improvements label Jul 26, 2025
Copy link
Member

@JasonGrace2282 JasonGrace2282 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a brief glance-through, this seems like an excellent thing to do! Thanks!

@github-project-automation github-project-automation bot moved this from 🆕 New to 👍 To be merged in Dev Board Aug 9, 2025
@chopan050 chopan050 enabled auto-merge (squash) August 9, 2025 17:30
@chopan050 chopan050 merged commit 05cc414 into ManimCommunity:main Aug 9, 2025
21 checks passed
@github-project-automation github-project-automation bot moved this from 👍 To be merged to ✅ Done in Dev Board Aug 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance refactoring, typos, removing clutter/dead code, and other code quality improvements
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants